package com.hqyj.manager.service.impl;

import com.hqyj.mapper.ProductMapper;
import com.hqyj.manager.service.MarketingService;
import com.hqyj.pojo.Product;
import com.hqyj.pojo.SeckillProduct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class MarketingServiceImpl implements MarketingService {


    @Autowired
    private RedisTemplate redisTemplate;

    @Resource
    private ProductMapper productMapper;

    @Override
    public List<SeckillProduct> findAllSeckill() {

        log.debug(redisTemplate.toString());

        Product product = productMapper.selectByPrimaryKey(1);
        log.debug(product.toString());

        //redisTemplate.boundHashOps("Seckill").put("shoubiao",product);

        List<SeckillProduct> seckillProducts = redisTemplate.boundHashOps("Seckill").values();

        SeckillProduct product1 = seckillProducts.get(0);

        log.debug(product1.toString());

        log.debug(seckillProducts.toString());

        return seckillProducts;
    }
}
